import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;

import java.io.IOException;

public class HBaseClientScan {
    public static void main(String[] args) throws IOException {
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum", "master");

        Connection connection = ConnectionFactory.createConnection(conf);

        String tableName = "test-hbase";
        String columnName = "info";
        String startRow = "rk1";
        String endRow = "rk5";
        String qulifier = "c1";
        String value = "value1";

        Table table = connection.getTable(TableName.valueOf(tableName));
        Scan scan = new Scan();

        scan.setStartRow(startRow.getBytes());
        scan.setStopRow(endRow.getBytes());
        scan.addColumn(columnName.getBytes(), qulifier.getBytes());
        ResultScanner rs = table.getScanner(scan);

        for (Result result:rs){
            String valueStr = Bytes.toString(result.getValue(columnName.getBytes(), qulifier.getBytes()));
            System.out.println(valueStr);
        }

        table.close();
        connection.close();
    }
}
